import request from "@/request/request";
import qs from "qs"

/**
 * 加载用户
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function getUserList(data){
    let url = "/admin/user";
    let param = {
        url:url,
        method:"GET",
        params:data
    }
    return request(param);
}


/**
 * 用户登录
 * @param loginInfo
 * @returns {Promise<AxiosResponse<any>>}
 */
export function login(loginInfo){
    let url = "/admin/user/login";
    let param = {
        url:url,
        method:"POST",
        data:qs.stringify(loginInfo)
    }
    return request(param);
}


export function saveUser(id,user){
    let method = "post";
    let url = "/admin/user";
    if(id){
        method = "put";
        url = "/admin/user/"+id;
    }

    let param = {
        url:url,
        method:method,
        data:qs.stringify(user)
    }
    return request(param);
}


export function deleteUserById(id){
    let param = {
        url:"/admin/user/"+id,
        method:"delete"
    }
    return request(param);
}


export function updateStatus(id,status){
    let param = {
        url:"/admin/user/"+id+"/status",
        method:"put",
        data:"status="+status
    }
    return request(param);
}






